package org.elasticsearch;

import com.obs.services.EcsObsCredentialsProvider;
import com.obs.services.ObsClient;
import com.obs.services.model.S3Bucket;
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
import org.elasticsearch.common.settings.Settings;

import java.util.List;


public class ObsServiceTest {

    @org.junit.jupiter.api.Test
    public void testObsService() {
        Settings settings2 = Settings.builder().put(ObsClientSettings.BUCKET.getKey(), "bucket")
                .put(ObsClientSettings.ACCESS_KEY.getKey(), "access_key")
                .put(ObsClientSettings.SECRET_ACCESS_KEY.getKey(), "secret_key")
                .put(ObsClientSettings.ENDPOINT.getKey(), "endpoint")
                .build();
        final RepositoryMetaData metadata1 = new RepositoryMetaData("first", ObsRepository.TYPE, settings2);
        ObsService obsService = new ObsService();
        final ObsReference reference = obsService.client(metadata1);
        List<S3Bucket> buckets= reference.client().listBuckets();

    }

    @org.junit.jupiter.api.Test
    public void createObsServiceByEcs() {
        ObsClient client = new ObsClient(new EcsObsCredentialsProvider(), "https://obs.cn-south-1.myhuaweicloud.com");
        System.out.println(client.listBuckets());
    }
}
